<template>
    <div>
        <!-- 面包屑导航 -->
        <el-breadcrumb separator="/">
            <el-breadcrumb-item to="/">首页</el-breadcrumb-item>
            <el-breadcrumb-item>权限管理</el-breadcrumb-item>
            <el-breadcrumb-item>资源列表</el-breadcrumb-item>
        </el-breadcrumb>

        <el-divider></el-divider>
        
        <div class="box">
            <el-row>
                <el-col :span="8">
                    <div class="grid-content bg-purple">
                        <h3 style="line-height:32px;">
                            <i class="el-icon-s-tools"></i> &nbsp; 管理信息
                        </h3>
                    </div>
                </el-col>
                <el-col :span="16" style="text-align: right;">
                    <div class="grid-content bg-purple">
                        <el-button size="small" type="primary" icon="el-icon-circle-plus-outline" @click="addDialogVisible = true">新增权限</el-button>
                        <el-button size="small" type="primary" icon="el-icon-remove-outline">删除权限</el-button>
                    </div>
                </el-col>
            </el-row>
            <div class="divider"></div>
            
            <el-row :gutter="15" class="whererow">
                <el-col :span="4">
                    <div class="grid-content bg-purple">
                        <p class="label">资源名称</p>
                        <el-input size="small" v-model="input" placeholder="资源名称"></el-input>
                    </div>
                </el-col>
                <el-col :span="4">
                    <div class="grid-content bg-purple">
                        <p class="label">资源路径</p>
                        <el-input size="small" v-model="input" placeholder="资源路径"></el-input>
                    </div>
                </el-col>
                <el-col :span="4">
                    <p class="label">&nbsp;</p>
                    <el-button type="primary" size="mini">查询</el-button>
                    <el-button type="primary" size="mini" plain>重置</el-button>
                </el-col>
            </el-row>

        </div>

        <div class="noticerow box">
            <i class="el-icon-edit"></i> &nbsp; 已选择了0项
        </div>

        <el-table border
            ref="multipleTable"
            :data="tableData"
            tooltip-effect="dark"
            style="width: 100%">
            <el-table-column align="center" type="selection" width="55"> </el-table-column>
            <el-table-column align="center" label="编号" width="60">
                <template slot-scope="scope">{{ scope.row.id }}</template>
            </el-table-column>
            <el-table-column align="center" label="资源名称">
                <template slot-scope="scope">{{ scope.row.name }}</template>
            </el-table-column>
            <el-table-column align="center" label="资源路径">
                <template slot-scope="scope">{{ scope.row.value }}</template>
            </el-table-column>
            <el-table-column align="center" label="资源描述">
                <template slot-scope="scope">{{ scope.row.description }}</template>
            </el-table-column>
            <el-table-column align="center" label="创建时间" width="200">
                <template slot-scope="scope">{{ scope.row.gmtCreate }}</template>
            </el-table-column>
            <el-table-column align="center" label="操作" width="170">
                <template slot-scope="scope">
                    <el-button title="编辑资源权限" type="warning" size="mini" icon="el-icon-edit" circle @click="editDialogVisible = true"></el-button>
                    <el-button title="删除资源权限" type="danger" size="mini" icon="el-icon-delete" circle @click="$router.push('#'+scope.row.id)"></el-button>
                </template>
            </el-table-column>
        </el-table>

        <div class="pagination">
            <el-pagination background 
                @current-change="handleCurrentChange"
                :current-page="currentPage"
                layout="total, prev, pager, next, jumper"
                :total="400">
            </el-pagination>
        </div>

        
        <!-- 新增资源的弹窗 -->
        <el-dialog width="40%" title="添加资源" :visible.sync="addDialogVisible" :modal-append-to-body="false">
            <el-row>
                <el-col :span="24">
                    <el-form ref="form" :model="cuser" label-width="80px" size="small">
                        <el-form-item label="资源名称">
                            <el-input v-model="cresource.name"></el-input>
                        </el-form-item>
                        <el-form-item label="资源路径">
                            <el-input type="password" v-model="cresource.value"></el-input>
                        </el-form-item>
                        <el-form-item label="资源描述">
                            <el-input type="textarea" v-model="cresource.description"></el-input>
                        </el-form-item>

                        <el-form-item size="large">
                            <el-button type="primary">保存</el-button>
                            <el-button>取消</el-button>
                        </el-form-item>
                    </el-form>
                </el-col>
            </el-row>
        </el-dialog>

        <!-- 修改资源的弹窗 -->
        <el-dialog width="40%" title="修改资源" :visible.sync="editDialogVisible" :modal-append-to-body="false">
            <el-row>
                <el-col :span="24">
                    <el-form ref="form" :model="cuser" label-width="80px" size="small">
                        <el-form-item label="资源名称">
                            <el-input v-model="cresource.name"></el-input>
                        </el-form-item>
                        <el-form-item label="资源路径">
                            <el-input type="password" v-model="cresource.value"></el-input>
                        </el-form-item>
                        <el-form-item label="资源描述">
                            <el-input type="textarea" v-model="cresource.description"></el-input>
                        </el-form-item>

                        <el-form-item size="large">
                            <el-button type="primary">保存</el-button>
                            <el-button>取消</el-button>
                        </el-form-item>
                    </el-form>
                </el-col>
            </el-row>
        </el-dialog>

        

    </div>
</template>

<script>
export default {
    data() {
        return {
            cresource: {},
            addDialogVisible: false,
            editDialogVisible: false,
            roleDialogVisible: false,
            search: '',
            selectRoles: '',

            currentPage: 3,
            input: '',
            value: '',
            options: [{
                value: 'enable',
                label: '启用'
            },{
                value: 'disable',
                label: '禁用'
            }],
            tableData: [{
                id: '01',
                name: '资源名称',
                value: '/product/xxx',
                description: '资源描述',
                gmtCreate: '2011-11-11 11:11:11'
            },{
                id: '01',
                name: '资源名称',
                value: '/product/xxx',
                description: '资源描述',
                gmtCreate: '2011-11-11 11:11:11'
            },{
                id: '01',
                name: '资源名称',
                value: '/product/xxx',
                description: '资源描述',
                gmtCreate: '2011-11-11 11:11:11'
            },{
                id: '01',
                name: '资源名称',
                value: '/product/xxx',
                description: '资源描述',
                gmtCreate: '2011-11-11 11:11:11'
            },]
        }
    },
    methods: {
        handleCurrentChange(val) {
            console.log(`当前页: ${val}`);
        }
    },
}
</script>
